<template>
  <div class="oneboard">
    <div class="oneboard-two">
      <div id="postponenum" class="echartsStyle"></div>
    </div>
    <div class="oneboard-three">
      <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="款号" class="myform-item">
          <el-input
            v-model="form.type_no"
            placeholder="请输入款号"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="RFID编码" class="myform-item">
          <el-input
            v-model="form.number"
            placeholder="请输入RFID编码"
            clearable
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="QC质检日期" class="myform-item">
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="form.qc_time"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item> -->
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSeach">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <el-table :data="tableData" style="width: 100%" border>
        <el-table-column label="款号" align="center" prop="type_no">
        </el-table-column>
        <el-table-column label="RFID编码" align="center" prop="number">
        </el-table-column>
        <el-table-column label="工厂名称" align="center" prop="factory_name">
        </el-table-column>
        <el-table-column label="验货期" align="center" prop="qc_time">
        </el-table-column>
        <el-table-column label="问题描述" align="center" prop="reason_title">
        </el-table-column>
        <el-table-column label="问题图片" align="center" prop="qc_img">
         <template slot-scope="{ row }">
           <el-image :src="row.qc_img" fit="contain" style="width:200px;height:200px" :preview-src-list="[row.qc_img]"></el-image>
         </template>
        </el-table-column>
      </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postApiCodeGetQtnopassdetaillist"
    />
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
import { postApiCodeGetQtlookdetail, postApiCodeGetQtnopassdetaillist } from "@/api"
import { postponenum } from '../AweekBoard/postponenum.js'
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      datastatistics:"",
      echartsData:"",
      date:"",
      tableData:[],
      total:0,
      type:"",
      form: {
        type:"",
        type_no: "",
        qc_time: "",
        number:"",
        page: 1,
        size: 10,
      },
    };
  },
  async activated() {
    // await this.postApiCodeGetQclookban()
    this.form.type = this.$route.query.type
    this.type = this.$route.query.type
    await this.postApiCodeGetQtlookdetail()
    await this.postponenum(postponenum(this.echartsData));
    this.postApiCodeGetQtnopassdetaillist(this.form)
  },
  methods: {
    async postponenum(data) {
      let myChart = echarts.init(document.getElementById("postponenum"));
      // 绘制图表
      myChart.setOption(data);
    },
    // 看板数据--图表
    async postApiCodeGetQtlookdetail(){
      let obj = {
        type: this.type
      }
      await postApiCodeGetQtlookdetail(obj).then(res=>{
        console.log("看板数据--图表",res)
        this.echartsData = res.data
        this.echartsData.type = this.type
      })
    },
    // 查询
    onSeach(){
      console.log(this.form)
      this.form.page = 1
      this.postApiCodeGetQtnopassdetaillist(this.form)
    },
    // 看板数据--列表
    postApiCodeGetQtnopassdetaillist(data){
      this.form = data;
      let form = JSON.parse(JSON.stringify(this.form));
      if (form.qc_time) {
        form.qc_time = `${form.qc_time[0]}/${form.qc_time[1]}`;
      }
      postApiCodeGetQtnopassdetaillist(data).then(res=>{
        console.log("看板数据--列表",)
        this.tableData = res.data
        this.total = Number(res.total)
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.echartsStyle {
  width: calc(100% - 40px);
  height: 400px;
}
.oneboard {
  > div {
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 20px;
  }
  &-one {
    > div:nth-child(1) {
      font-size: 18px;
      font-weight: 800;
      margin-bottom: 20px;
    }
    > div:nth-child(2) {
      display: flex;
      justify-content: space-around;
      align-items: center;
      > div {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        > div:nth-child(1) {
          color: #999;
          font-size: 14px;
          padding-bottom: 10px;
        }
        > div:nth-child(2) {
          font-size: 18px;
          font-weight: 600;
        }
      }
      > div:nth-child(2n) {
        width: 1px;
        height: 15px;
        background: #f0f1f7;
      }
    }
  }
}
</style>